//
//  CSBActiveCell.swift
//  CurSodoboAer
//
//  Created by CurSodoboAer on 2024/11/6.
//

import UIKit

class CSBActiveListCell: UICollectionViewCell {
    
    
    private let daDymbgCSB = UIImageView()
    private let uderTimeCSB = UILabel()
    private let uderNamerCSB = UILabel()
    
    private let joineCSB = UIImageView()
    
  
    
    func comekwith(uhuie:Dictionary<String,String>) {
        daDymbgCSB.image = UIImage(named: uhuie["csbActiveCover"] ?? "")
        joineCSB.image =  UIImage(named: "btnJoined")
        uderNamerCSB.text =  uhuie["csbActiveName"] ?? ""
        uderTimeCSB.text = uhuie["csbActiveTimeDateWai"] ?? "Dec.12"
      
        let imgnajelisr = (uhuie["csbJoinHeaer"] ?? "").components(separatedBy: "*")
        for (kk,item )in imgnajelisr.enumerated() {
            let hedCSB = UIImageView(image: UIImage.init(named: item))
            hedCSB.layer.cornerRadius = 18.xQQ
            hedCSB.layer.masksToBounds = true
            
            hedCSB.contentMode = .scaleAspectFill
            contentView.addSubview(hedCSB)
            hedCSB.snp.makeConstraints { make in
                make.leading.equalToSuperview().offset(16 + 20*kk )
                make.bottom.equalToSuperview().offset(-12)
                make.width.height.equalTo(36.xQQ)
            }
        }
        
    }
    
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.backgroundColor = .clear
        daDymbgCSB.layer.cornerRadius = 28.xQQ
        daDymbgCSB.layer.masksToBounds = true
        daDymbgCSB.contentMode = .scaleAspectFill

        uderTimeCSB.layer.borderWidth = 2
        
        uderTimeCSB.layer.borderColor = UIColor(red: 0.64, green: 0.41, blue: 0.98, alpha: 0.5).cgColor
        uderTimeCSB.layer.cornerRadius = 57.xQQ
        uderTimeCSB.layer.masksToBounds = true
        joineCSB.contentMode = .scaleAspectFill

        uderNamerCSB.textColor = .white
        uderNamerCSB.textAlignment = .center
        uderNamerCSB.font = UIFont(name: "Helvetica Bold", size: 15)
        
        
        uderTimeCSB.textColor = .white
        uderTimeCSB.textAlignment = .center
        uderTimeCSB.font = UIFont(name: "Helvetica", size: 12)
        uderTimeCSB.backgroundColor = UIColor(red: 0.07, green: 0.07, blue: 0.07, alpha: 1)
        uderTimeCSB.layer.masksToBounds = true
        uderTimeCSB.layer.cornerRadius = 12.xQQ
       
        
        addAotherCSB()
    }
    
    
    private  func addAotherCSB()  {
        contentView.addSubview(daDymbgCSB)
        contentView.addSubview(uderTimeCSB)
       
        contentView.addSubview(joineCSB)
        contentView.addSubview(uderNamerCSB)
       
        daDymbgCSB.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
        joineCSB.contentMode = .scaleAspectFit
        joineCSB.snp.makeConstraints { make in
            make.width.equalTo(96.xQQ)
            make.height.equalTo(46.xQQ)
            make.bottom.right.equalToSuperview()
           
        }
        
        uderNamerCSB.snp.makeConstraints { make in
            make.leading.equalToSuperview().offset(16.xQQ)
            make.bottom.equalToSuperview().offset(-60)
        }
        
        uderTimeCSB.snp.makeConstraints { make in
            make.trailing.equalToSuperview().offset(-11)
            make.width.equalTo(65)
            make.height.equalTo(25)
            make.top.equalToSuperview().offset(9)
        }
  
    }
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
